using System;
using System.Collections;
using NUnit.Framework;
using PhillyCodeCamp.UI;
using PhillyCodeCampSpecs.Helpers;

namespace PhillyCodeCampSpecs.UI
{
    [TestFixture]
    public class when_displaying_the_tax_calculator
    {

        [Test]
        public void should_display_the_list_of_states()
        {
            var view= new StubTaxCalculatorView();
            var taxService = new StubTaxService();
            const bool validInputs = true;
            var validatorService = new StubValidatorService(validInputs);

            var systemUnderTest = new TaxCalculatorPresenter (view, taxService, validatorService);

            systemUnderTest.OnViewInitialized();

            Assert.IsTrue(view.NumberOfStatesDisplayed > 0);

        }
    }

    [TestFixture]
    public class when_submiting_the_tax_calculator_with_valid_inputs
    {
        [Test]
        public void should_compute_the_tax()
        {
            var view = new StubTaxCalculatorView();
            var taxService = new StubTaxService();

            const bool validInputs = true;
            var validatorService = new StubValidatorService(validInputs);

            var systemUnderTest = new TaxCalculatorPresenter(view, taxService, validatorService);

            systemUnderTest.ComputeTax();

            Assert.IsTrue(taxService.TaxWasComputed);

        }
    }

    [TestFixture]
    public class when_submiting_the_tax_calculator_with_invalid_inputs
    {
        private TaxCalculatorPresenter _systemUnderTest;
        private StubTaxCalculatorView _stubView;
        private StubTaxService _stubTaxService;

        [Test]
        public void should_not_compute_the_tax()
        {
            _systemUnderTest.ComputeTax();

            Assert.IsFalse(_stubTaxService.TaxWasComputed);

        }
        [Test]
        public void should_should_error_message()
        {
            _systemUnderTest.ComputeTax();

            Assert.IsTrue(_stubView.ErrorsWereShown);

        }

        [TestFixtureSetUp]
        public void Context ()
        {
            _stubView = new StubTaxCalculatorView();
            _stubTaxService = new StubTaxService();
            const bool validInputs = false;
            var stubValidatorService = new StubValidatorService(validInputs);

            _systemUnderTest = new TaxCalculatorPresenter(_stubView, _stubTaxService, stubValidatorService);
        }
    }

}